import React, { useState, useEffect } from 'react';
import styles from './index.less';
import CardCommon from '@/compontents/cardCommon';
import lhTool from 'lh-tool';
import api from '@/http/api';
import { PlusOutlined } from '@ant-design/icons';
import TablePage from '@/compontents/tablePage';

export default (props: any) => {
  const { schoolId } = JSON.parse(sessionStorage.info).userInfo;
  const col = [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      align: 'center',
      width: 100,
      render: (text: any, record: any, index: any) => `${index + 1}`,
    },
    {
      title: '姓名',
      dataIndex: 'name',
    },
    {
      title: '联系方式',
      dataIndex: 'tel',
    },
    {
      title: '商户名称',
      dataIndex: 'businessName',
    },
    {
      title: '地址',
      dataIndex: 'address',
    },
  ];
  const [list, setList] = useState([]);
  const getList = () => {
    api
      .bussinessGet({
        uSchoolId: schoolId,
      })
      .then(res => {
        const _data: any = [...res.data];
        _data.map((item: any) => {
          item.key = item.id;
        });
        setList(_data);
      });
  };
  useEffect(() => {
    getList();
  }, []);
  // const [total,useTotal] =
  return (
    <CardCommon>
      <div className={styles.wrap}>
        <TablePage col={col} list={list} />
      </div>
    </CardCommon>
  );
};
